package com.itheima.homework15;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.util.Scanner;

/*
请编写程序，分别模拟使用UDP协议发送和接收数据的两个设备，
发送端数据由键盘录入，发送给接收端。接收端接收到数据，打印到控制台。效果如下：
 */
public class Test01 {
    public static void main(String[] args) throws Exception {
        DatagramSocket socket=new DatagramSocket();
        Scanner sc=new Scanner(System.in);

        while (true) {
            String s=sc.nextLine();
            if("over".equals(s)){
                break;
            }
            byte[] bytes = s.getBytes();
            InetAddress byName = InetAddress.getByName("192.168.13.24");
            DatagramPacket packet=new DatagramPacket(bytes,bytes.length,byName,10086);
            socket.send(packet);
        }
    }
}
